package com.example.kotlindemo.http

import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory

class RetrofitHelper private constructor() {
    private val baseUrl = "https://api.vvhan.com/api/"
    private val retrofit: Retrofit = Retrofit.Builder()
        .baseUrl(baseUrl)
        .addConverterFactory(GsonConverterFactory.create())
        .build()

    companion object{
        private var instance:RetrofitHelper? = null
        @Synchronized fun getInstances():RetrofitHelper{
            if(instance == null)
                instance = RetrofitHelper()
            return instance!!
        }
        fun getMovieServer():DoubanApi{
            return getInstances().retrofit.create(DoubanApi::class.java)
        }
    }
}